# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('libtool' 'libltdl')
pkgver=2.4.6
_gccver=4.9.2
pkgrel=1
pkgdesc="A generic library support script"
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/libtool"
license=('GPL')
makedepends=("gcc=${_gccver}")
source=(ftp://ftp.gnu.org/pub/gnu/libtool/${pkgname}-${pkgver}.tar.xz{,.sig}
        #ftp://alpha.gnu.org/gnu/libtool/${pkgname}-${pkgver}.tar.xz{,.sig}
        0002-cygwin-mingw-Create-UAC-manifest-files.mingw.patch
        0003-Pass-various-runtime-library-flags-to-GCC.mingw.patch
        0005-Fix-seems-to-be-moved.patch
        0006-Fix-strict-ansi-vs-posix.patch
        0007-fix-cr-for-awk-in-configure.all.patch
        0009-libtool-2.4.2.418-msysize.patch
        0010-libtool-2.4.2-include-process-h.patch)
md5sums=('1bfb9b923f2c1339b4d2ce1807064aa5'
         'SKIP'
         '091163f2cc8c2dd8c8d5574181eb53e1'
         '2396f4f169edb316d8d076897ff03347'
         'bb4e559afa91865c0f9e489e19507922'
         'cfc5378b9d8ac56800489841b8b90101'
         '2200a7e2cfa8f5f3f9811f03ed41c46a'
         '34cd86db45d81126a3110bcdf4dd1c95'
         'b2203a93dc061cd64c5b33f1524c9d94')

prepare() {
  cd ${srcdir}/${pkgbase}-${pkgver}

  patch -p1 -i ${srcdir}/0002-cygwin-mingw-Create-UAC-manifest-files.mingw.patch
  patch -p1 -i ${srcdir}/0003-Pass-various-runtime-library-flags-to-GCC.mingw.patch
  patch -p1 -i ${srcdir}/0005-Fix-seems-to-be-moved.patch
  patch -p1 -i ${srcdir}/0006-Fix-strict-ansi-vs-posix.patch
  patch -p1 -i ${srcdir}/0007-fix-cr-for-awk-in-configure.all.patch

  patch -p1 -i ${srcdir}/0009-libtool-2.4.2.418-msysize.patch
  patch -p1 -i ${srcdir}/0010-libtool-2.4.2-include-process-h.patch

}

build() {
  cd ${srcdir}/${pkgbase}-${pkgver}
  ./configure --prefix=/usr
  make
}

check() {
  cd ${srcdir}/${pkgbase}-${pkgver}
  make check
}

package_libtool() {
  depends=('sh' "libltdl=${pkgver}" 'tar')
  groups=('base-devel')
  install=libtool.install

  cd ${srcdir}/${pkgbase}-${pkgver}

  make DESTDIR=${pkgdir} install-binSCRIPTS install-man install-info \
                         install-data-local
}

package_libltdl() {
  pkgdesc="A system independent dlopen wrapper for GNU libtool"
  options=('staticlibs')

  cd ${srcdir}/${pkgbase}-${pkgver}
  make DESTDIR=${pkgdir} install-libLTLIBRARIES install-includeHEADERS \
                         install-ltdlincludeHEADERS
}
